package com.bii.gelapp;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;

public class CompareEditDialog extends Dialog {
	public Context Markercontext;
	EditText etValue;
	int index;
	int value;

	public CompareEditDialog(Context context, int index) {
		super(context);
		this.index = index;
		this.Markercontext = context;
		Log.d("tag1", "index: " + index);

	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.markervaluedialog);

		WindowManager.LayoutParams wmlp = this.getWindow().getAttributes();
		WindowManager wm = (WindowManager) this.Markercontext
				.getSystemService(Context.WINDOW_SERVICE);
		Display display = wm.getDefaultDisplay();
		wmlp.gravity = Gravity.CENTER_VERTICAL;
		wmlp.width = display.getWidth();

		int value = CompareFullScreenActivity.markervalues.get(index);

		etValue = (EditText) findViewById(R.id.etValue);
		etValue.setText("" + value);
		Button btConfirm = (Button) findViewById(R.id.btConfirm);
		btConfirm.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				int valuechanged = Integer.parseInt(etValue.getText()
						.toString());
				CompareFullScreenActivity.markervalues.set(index, valuechanged);
				// int valuetochange = (Integer)
				// CompareFullScreenActivity.markervalues.get(index);
				// valuetochange = valuechanged;
				dismiss();
			}
		});
		Button btCancel = (Button) findViewById(R.id.btCancel);
		btCancel.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dismiss();
			}
		});

	}
}
